using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using log4net;
using log4net.Repository.Hierarchy;

namespace SharePointSearchBench.Library.Logging
{

    /// <summary>
    /// Used for writing information messages to a log.
    /// </summary>
    public class InfoLogWriter
    {
        private static readonly ILog Logger = LogManager.GetLogger(LoggerMessage.LoggingApplication);

        internal static void WriteMessageInternal(string message)
        {
            if (Logger.IsInfoEnabled)
            {
                StackTrace st = new StackTrace(true);
                StackFrame frame = st.GetFrame(2); // Gets the frame that called this function
                Logger.Info(LoggerMessage.CreateMessage(message, frame));
            }
        }

        /// <summary>
        /// Writes an information messages to a log.
        /// </summary>
        /// <param name="message"></param>
        public static void WriteMessage(string message)
        {
            if (Logger.IsInfoEnabled)
            {
                StackTrace st = new StackTrace(true);
                StackFrame frame = st.GetFrame(1); // Gets the frame that called this function
                Logger.Info(LoggerMessage.CreateMessage(message, frame));
            }
        }
    }
}
